<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
var deleteNode = function(head, val) {
    if(head.val==val){
        head = head.next
        return head
    }
    let current = head
    let prev
    while(current.next!=null){
        prev = current
        current = current.next
        if(current.val == val){
            prev.next = current.next
            return head
        }
    }
};
    </script>
</body>
</html>